<?php


abstract class BaseUserPeer {

	
	const DATABASE_NAME = 'propel';

	
	const TABLE_NAME = 'tech_user';

	
	const CLASS_DEFAULT = 'lib.model.User';

	
	const NUM_COLUMNS = 38;

	
	const NUM_LAZY_LOAD_COLUMNS = 0;


	
	const ID = 'tech_user.ID';

	
	const TYPE = 'tech_user.TYPE';

	
	const FIRST_NAME = 'tech_user.FIRST_NAME';

	
	const LAST_NAME = 'tech_user.LAST_NAME';

	
	const EMAIL = 'tech_user.EMAIL';

	
	const NICKNAME = 'tech_user.NICKNAME';

	
	const NOTIFICATIONS = 'tech_user.NOTIFICATIONS';

	
	const MSN = 'tech_user.MSN';

	
	const YAHOO = 'tech_user.YAHOO';

	
	const ICQ = 'tech_user.ICQ';

	
	const SKYPE = 'tech_user.SKYPE';

	
	const GTALK = 'tech_user.GTALK';

	
	const AIM = 'tech_user.AIM';

	
	const TWITTER = 'tech_user.TWITTER';

	
	const LOCATION = 'tech_user.LOCATION';

	
	const VENTURES = 'tech_user.VENTURES';

	
	const WEBSITE = 'tech_user.WEBSITE';

	
	const RAISEDMONEY = 'tech_user.RAISEDMONEY';

	
	const VENTURERAISED = 'tech_user.VENTURERAISED';

	
	const LINKEDIN = 'tech_user.LINKEDIN';

	
	const FACEBOOK = 'tech_user.FACEBOOK';

	
	const AVATARURL = 'tech_user.AVATARURL';

	
	const ZIPCODE = 'tech_user.ZIPCODE';

	
	const COUNTRY = 'tech_user.COUNTRY';

	
	const STATE = 'tech_user.STATE';

	
	const AGE = 'tech_user.AGE';

	
	const RELOCATION = 'tech_user.RELOCATION';

	
	const YEXPERIENCE = 'tech_user.YEXPERIENCE';

	
	const CANWORKAS = 'tech_user.CANWORKAS';

	
	const RESUMEURL = 'tech_user.RESUMEURL';

	
	const EXPEQUITY = 'tech_user.EXPEQUITY';

	
	const READYCOMMITMENT = 'tech_user.READYCOMMITMENT';

	
	const AVATAR_ID = 'tech_user.AVATAR_ID';

	
	const PASSWORD_SHA1 = 'tech_user.PASSWORD_SHA1';

	
	const SALT = 'tech_user.SALT';

	
	const INVITED = 'tech_user.INVITED';

	
	const CREATED_AT = 'tech_user.CREATED_AT';

	
	const UPDATED_AT = 'tech_user.UPDATED_AT';

	
	private static $phpNameMap = null;


	
	private static $fieldNames = array (
		BasePeer::TYPE_PHPNAME => array ('Id', 'Type', 'FirstName', 'LastName', 'Email', 'Nickname', 'Notifications', 'Msn', 'Yahoo', 'Icq', 'Skype', 'Gtalk', 'Aim', 'Twitter', 'Location', 'Ventures', 'Website', 'Raisedmoney', 'Ventureraised', 'Linkedin', 'Facebook', 'Avatarurl', 'Zipcode', 'Country', 'State', 'Age', 'Relocation', 'Yexperience', 'Canworkas', 'Resumeurl', 'Expequity', 'Readycommitment', 'AvatarId', 'PasswordSha1', 'Salt', 'Invited', 'CreatedAt', 'UpdatedAt', ),
		BasePeer::TYPE_COLNAME => array (UserPeer::ID, UserPeer::TYPE, UserPeer::FIRST_NAME, UserPeer::LAST_NAME, UserPeer::EMAIL, UserPeer::NICKNAME, UserPeer::NOTIFICATIONS, UserPeer::MSN, UserPeer::YAHOO, UserPeer::ICQ, UserPeer::SKYPE, UserPeer::GTALK, UserPeer::AIM, UserPeer::TWITTER, UserPeer::LOCATION, UserPeer::VENTURES, UserPeer::WEBSITE, UserPeer::RAISEDMONEY, UserPeer::VENTURERAISED, UserPeer::LINKEDIN, UserPeer::FACEBOOK, UserPeer::AVATARURL, UserPeer::ZIPCODE, UserPeer::COUNTRY, UserPeer::STATE, UserPeer::AGE, UserPeer::RELOCATION, UserPeer::YEXPERIENCE, UserPeer::CANWORKAS, UserPeer::RESUMEURL, UserPeer::EXPEQUITY, UserPeer::READYCOMMITMENT, UserPeer::AVATAR_ID, UserPeer::PASSWORD_SHA1, UserPeer::SALT, UserPeer::INVITED, UserPeer::CREATED_AT, UserPeer::UPDATED_AT, ),
		BasePeer::TYPE_FIELDNAME => array ('id', 'type', 'first_name', 'last_name', 'email', 'nickname', 'notifications', 'msn', 'yahoo', 'icq', 'skype', 'gtalk', 'aim', 'twitter', 'location', 'ventures', 'website', 'raisedmoney', 'ventureraised', 'linkedin', 'facebook', 'avatarurl', 'zipcode', 'country', 'state', 'age', 'relocation', 'yexperience', 'canworkas', 'resumeurl', 'expequity', 'readycommitment', 'avatar_id', 'password_sha1', 'salt', 'invited', 'created_at', 'updated_at', ),
		BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, )
	);

	
	private static $fieldKeys = array (
		BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Type' => 1, 'FirstName' => 2, 'LastName' => 3, 'Email' => 4, 'Nickname' => 5, 'Notifications' => 6, 'Msn' => 7, 'Yahoo' => 8, 'Icq' => 9, 'Skype' => 10, 'Gtalk' => 11, 'Aim' => 12, 'Twitter' => 13, 'Location' => 14, 'Ventures' => 15, 'Website' => 16, 'Raisedmoney' => 17, 'Ventureraised' => 18, 'Linkedin' => 19, 'Facebook' => 20, 'Avatarurl' => 21, 'Zipcode' => 22, 'Country' => 23, 'State' => 24, 'Age' => 25, 'Relocation' => 26, 'Yexperience' => 27, 'Canworkas' => 28, 'Resumeurl' => 29, 'Expequity' => 30, 'Readycommitment' => 31, 'AvatarId' => 32, 'PasswordSha1' => 33, 'Salt' => 34, 'Invited' => 35, 'CreatedAt' => 36, 'UpdatedAt' => 37, ),
		BasePeer::TYPE_COLNAME => array (UserPeer::ID => 0, UserPeer::TYPE => 1, UserPeer::FIRST_NAME => 2, UserPeer::LAST_NAME => 3, UserPeer::EMAIL => 4, UserPeer::NICKNAME => 5, UserPeer::NOTIFICATIONS => 6, UserPeer::MSN => 7, UserPeer::YAHOO => 8, UserPeer::ICQ => 9, UserPeer::SKYPE => 10, UserPeer::GTALK => 11, UserPeer::AIM => 12, UserPeer::TWITTER => 13, UserPeer::LOCATION => 14, UserPeer::VENTURES => 15, UserPeer::WEBSITE => 16, UserPeer::RAISEDMONEY => 17, UserPeer::VENTURERAISED => 18, UserPeer::LINKEDIN => 19, UserPeer::FACEBOOK => 20, UserPeer::AVATARURL => 21, UserPeer::ZIPCODE => 22, UserPeer::COUNTRY => 23, UserPeer::STATE => 24, UserPeer::AGE => 25, UserPeer::RELOCATION => 26, UserPeer::YEXPERIENCE => 27, UserPeer::CANWORKAS => 28, UserPeer::RESUMEURL => 29, UserPeer::EXPEQUITY => 30, UserPeer::READYCOMMITMENT => 31, UserPeer::AVATAR_ID => 32, UserPeer::PASSWORD_SHA1 => 33, UserPeer::SALT => 34, UserPeer::INVITED => 35, UserPeer::CREATED_AT => 36, UserPeer::UPDATED_AT => 37, ),
		BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'type' => 1, 'first_name' => 2, 'last_name' => 3, 'email' => 4, 'nickname' => 5, 'notifications' => 6, 'msn' => 7, 'yahoo' => 8, 'icq' => 9, 'skype' => 10, 'gtalk' => 11, 'aim' => 12, 'twitter' => 13, 'location' => 14, 'ventures' => 15, 'website' => 16, 'raisedmoney' => 17, 'ventureraised' => 18, 'linkedin' => 19, 'facebook' => 20, 'avatarurl' => 21, 'zipcode' => 22, 'country' => 23, 'state' => 24, 'age' => 25, 'relocation' => 26, 'yexperience' => 27, 'canworkas' => 28, 'resumeurl' => 29, 'expequity' => 30, 'readycommitment' => 31, 'avatar_id' => 32, 'password_sha1' => 33, 'salt' => 34, 'invited' => 35, 'created_at' => 36, 'updated_at' => 37, ),
		BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, )
	);

	
	public static function getMapBuilder()
	{
		include_once 'lib/model/map/UserMapBuilder.php';
		return BasePeer::getMapBuilder('lib.model.map.UserMapBuilder');
	}
	
	public static function getPhpNameMap()
	{
		if (self::$phpNameMap === null) {
			$map = UserPeer::getTableMap();
			$columns = $map->getColumns();
			$nameMap = array();
			foreach ($columns as $column) {
				$nameMap[$column->getPhpName()] = $column->getColumnName();
			}
			self::$phpNameMap = $nameMap;
		}
		return self::$phpNameMap;
	}
	
	static public function translateFieldName($name, $fromType, $toType)
	{
		$toNames = self::getFieldNames($toType);
		$key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null;
		if ($key === null) {
			throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true));
		}
		return $toNames[$key];
	}

	

	static public function getFieldNames($type = BasePeer::TYPE_PHPNAME)
	{
		if (!array_key_exists($type, self::$fieldNames)) {
			throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM. ' . $type . ' was given.');
		}
		return self::$fieldNames[$type];
	}

	
	public static function alias($alias, $column)
	{
		return str_replace(UserPeer::TABLE_NAME.'.', $alias.'.', $column);
	}

	
	public static function addSelectColumns(Criteria $criteria)
	{

		$criteria->addSelectColumn(UserPeer::ID);

		$criteria->addSelectColumn(UserPeer::TYPE);

		$criteria->addSelectColumn(UserPeer::FIRST_NAME);

		$criteria->addSelectColumn(UserPeer::LAST_NAME);

		$criteria->addSelectColumn(UserPeer::EMAIL);

		$criteria->addSelectColumn(UserPeer::NICKNAME);

		$criteria->addSelectColumn(UserPeer::NOTIFICATIONS);

		$criteria->addSelectColumn(UserPeer::MSN);

		$criteria->addSelectColumn(UserPeer::YAHOO);

		$criteria->addSelectColumn(UserPeer::ICQ);

		$criteria->addSelectColumn(UserPeer::SKYPE);

		$criteria->addSelectColumn(UserPeer::GTALK);

		$criteria->addSelectColumn(UserPeer::AIM);

		$criteria->addSelectColumn(UserPeer::TWITTER);

		$criteria->addSelectColumn(UserPeer::LOCATION);

		$criteria->addSelectColumn(UserPeer::VENTURES);

		$criteria->addSelectColumn(UserPeer::WEBSITE);

		$criteria->addSelectColumn(UserPeer::RAISEDMONEY);

		$criteria->addSelectColumn(UserPeer::VENTURERAISED);

		$criteria->addSelectColumn(UserPeer::LINKEDIN);

		$criteria->addSelectColumn(UserPeer::FACEBOOK);

		$criteria->addSelectColumn(UserPeer::AVATARURL);

		$criteria->addSelectColumn(UserPeer::ZIPCODE);

		$criteria->addSelectColumn(UserPeer::COUNTRY);

		$criteria->addSelectColumn(UserPeer::STATE);

		$criteria->addSelectColumn(UserPeer::AGE);

		$criteria->addSelectColumn(UserPeer::RELOCATION);

		$criteria->addSelectColumn(UserPeer::YEXPERIENCE);

		$criteria->addSelectColumn(UserPeer::CANWORKAS);

		$criteria->addSelectColumn(UserPeer::RESUMEURL);

		$criteria->addSelectColumn(UserPeer::EXPEQUITY);

		$criteria->addSelectColumn(UserPeer::READYCOMMITMENT);

		$criteria->addSelectColumn(UserPeer::AVATAR_ID);

		$criteria->addSelectColumn(UserPeer::PASSWORD_SHA1);

		$criteria->addSelectColumn(UserPeer::SALT);

		$criteria->addSelectColumn(UserPeer::INVITED);

		$criteria->addSelectColumn(UserPeer::CREATED_AT);

		$criteria->addSelectColumn(UserPeer::UPDATED_AT);

	}

	const COUNT = 'COUNT(tech_user.ID)';
	const COUNT_DISTINCT = 'COUNT(DISTINCT tech_user.ID)';

	
	public static function doCount(Criteria $criteria, $distinct = false, $con = null)
	{
				$criteria = clone $criteria;

				$criteria->clearSelectColumns()->clearOrderByColumns();
		if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
			$criteria->addSelectColumn(UserPeer::COUNT_DISTINCT);
		} else {
			$criteria->addSelectColumn(UserPeer::COUNT);
		}

				foreach($criteria->getGroupByColumns() as $column)
		{
			$criteria->addSelectColumn($column);
		}

		$rs = UserPeer::doSelectRS($criteria, $con);
		if ($rs->next()) {
			return $rs->getInt(1);
		} else {
						return 0;
		}
	}
	
	public static function doSelectOne(Criteria $criteria, $con = null)
	{
		$critcopy = clone $criteria;
		$critcopy->setLimit(1);
		$objects = UserPeer::doSelect($critcopy, $con);
		if ($objects) {
			return $objects[0];
		}
		return null;
	}
	
	public static function doSelect(Criteria $criteria, $con = null)
	{
		return UserPeer::populateObjects(UserPeer::doSelectRS($criteria, $con));
	}
	
	public static function doSelectRS(Criteria $criteria, $con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection(self::DATABASE_NAME);
		}

		if (!$criteria->getSelectColumns()) {
			$criteria = clone $criteria;
			UserPeer::addSelectColumns($criteria);
		}

				$criteria->setDbName(self::DATABASE_NAME);

						return BasePeer::doSelect($criteria, $con);
	}
	
	public static function populateObjects(ResultSet $rs)
	{
		$results = array();
	
				$cls = UserPeer::getOMClass();
		$cls = Propel::import($cls);
				while($rs->next()) {
		
			$obj = new $cls();
			$obj->hydrate($rs);
			$results[] = $obj;
			
		}
		return $results;
	}
	
	public static function getTableMap()
	{
		return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME);
	}

	
	public static function getOMClass()
	{
		return UserPeer::CLASS_DEFAULT;
	}

	
	public static function doInsert($values, $con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection(self::DATABASE_NAME);
		}

		if ($values instanceof Criteria) {
			$criteria = clone $values; 		} else {
			$criteria = $values->buildCriteria(); 		}

		$criteria->remove(UserPeer::ID); 

				$criteria->setDbName(self::DATABASE_NAME);

		try {
									$con->begin();
			$pk = BasePeer::doInsert($criteria, $con);
			$con->commit();
		} catch(PropelException $e) {
			$con->rollback();
			throw $e;
		}

		return $pk;
	}

	
	public static function doUpdate($values, $con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection(self::DATABASE_NAME);
		}

		$selectCriteria = new Criteria(self::DATABASE_NAME);

		if ($values instanceof Criteria) {
			$criteria = clone $values; 
			$comparison = $criteria->getComparison(UserPeer::ID);
			$selectCriteria->add(UserPeer::ID, $criteria->remove(UserPeer::ID), $comparison);

		} else { 			$criteria = $values->buildCriteria(); 			$selectCriteria = $values->buildPkeyCriteria(); 		}

				$criteria->setDbName(self::DATABASE_NAME);

		return BasePeer::doUpdate($selectCriteria, $criteria, $con);
	}

	
	public static function doDeleteAll($con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection(self::DATABASE_NAME);
		}
		$affectedRows = 0; 		try {
									$con->begin();
			$affectedRows += BasePeer::doDeleteAll(UserPeer::TABLE_NAME, $con);
			$con->commit();
			return $affectedRows;
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	 public static function doDelete($values, $con = null)
	 {
		if ($con === null) {
			$con = Propel::getConnection(UserPeer::DATABASE_NAME);
		}

		if ($values instanceof Criteria) {
			$criteria = clone $values; 		} elseif ($values instanceof User) {

			$criteria = $values->buildPkeyCriteria();
		} else {
						$criteria = new Criteria(self::DATABASE_NAME);
			$criteria->add(UserPeer::ID, (array) $values, Criteria::IN);
		}

				$criteria->setDbName(self::DATABASE_NAME);

		$affectedRows = 0; 
		try {
									$con->begin();
			
			$affectedRows += BasePeer::doDelete($criteria, $con);
			$con->commit();
			return $affectedRows;
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	public static function doValidate(User $obj, $cols = null)
	{
		$columns = array();

		if ($cols) {
			$dbMap = Propel::getDatabaseMap(UserPeer::DATABASE_NAME);
			$tableMap = $dbMap->getTable(UserPeer::TABLE_NAME);

			if (! is_array($cols)) {
				$cols = array($cols);
			}

			foreach($cols as $colName) {
				if ($tableMap->containsColumn($colName)) {
					$get = 'get' . $tableMap->getColumn($colName)->getPhpName();
					$columns[$colName] = $obj->$get();
				}
			}
		} else {

		}

		$res =  BasePeer::doValidate(UserPeer::DATABASE_NAME, UserPeer::TABLE_NAME, $columns);
    if ($res !== true) {
        $request = sfContext::getInstance()->getRequest();
        foreach ($res as $failed) {
            $col = UserPeer::translateFieldname($failed->getColumn(), BasePeer::TYPE_COLNAME, BasePeer::TYPE_PHPNAME);
            $request->setError($col, $failed->getMessage());
        }
    }

    return $res;
	}

	
	public static function retrieveByPK($pk, $con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection(self::DATABASE_NAME);
		}

		$criteria = new Criteria(UserPeer::DATABASE_NAME);

		$criteria->add(UserPeer::ID, $pk);


		$v = UserPeer::doSelect($criteria, $con);

		return !empty($v) > 0 ? $v[0] : null;
	}

	
	public static function retrieveByPKs($pks, $con = null)
	{
		if ($con === null) {
			$con = Propel::getConnection(self::DATABASE_NAME);
		}

		$objs = null;
		if (empty($pks)) {
			$objs = array();
		} else {
			$criteria = new Criteria();
			$criteria->add(UserPeer::ID, $pks, Criteria::IN);
			$objs = UserPeer::doSelect($criteria, $con);
		}
		return $objs;
	}

} 
if (Propel::isInit()) {
			try {
		BaseUserPeer::getMapBuilder();
	} catch (Exception $e) {
		Propel::log('Could not initialize Peer: ' . $e->getMessage(), Propel::LOG_ERR);
	}
} else {
			require_once 'lib/model/map/UserMapBuilder.php';
	Propel::registerMapBuilder('lib.model.map.UserMapBuilder');
}
